; while (I Time Complexity AnalysisThe time is mainly spent on comparing and moving data elements.First, check whether the node with the value of x exists in the linear table L;Secondly, if a node with the value of x exists and its position in linear table L is I, the element I is deleted in linear table L.In the linear table L, the probability of deleting data elements is Pi, without losing its universality. If the probability of each position is equal, Pi = 1/n.◆ Average number of comparisons:
(x);}}Find-and-locate deletion of sequential linear tableIn linear table l= (a1,a2,...,an), delete the first node with the value x.Implementation steps(1) Look for the first Data element with the value x in the Linear table L.(2) Move one position forward from the found position to the last node in turn.(3) Linear table length minus 1.Algorithm descriptionStatus locate_delete_sqlist (sqlist *l,elemtype x)/ * Delete the first node of the linear table L with a value of X * /{intI=0K while(ilength)
, k; while (I Time Complexity Analysis
The time is mainly spent on comparing and moving data elements.
First, check whether the node with the value of x exists in the linear table L;Secondly, if a node with the value of x exists and its position in linear table L is I, the element I is deleted in linear table L.In the linear table L, the probability of deleting data elements is Pi, without losing its universality. If the probability of each position is equal, Pi = 1/n.◆ Average number of compari
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.